package cn.lf.utils;

import cn.hutool.core.codec.Base64;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import org.bouncycastle.jce.provider.BouncyCastleProvider;

import javax.crypto.Cipher;
import javax.crypto.spec.IvParameterSpec;
import javax.crypto.spec.SecretKeySpec;
import java.security.AlgorithmParameters;
import java.security.Security;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;

public class WechatUtil {

    public static JSONObject getSessionKeyOrOpenId(String code){
        String requestUrl = "https://api.weixin.qq.com/sns/jscode2session";
        Map<String, String> requestUrlParam = new HashMap<>();
        requestUrlParam.put("appid","wx9b1cfa5431fd27b3");
        requestUrlParam.put("secret","54e7c24730f11e318d8bd30d6cb049f5");
        requestUrlParam.put("js_code",code);
        requestUrlParam.put("grant_type","authorization_code");
        JSONObject jsonObject = JSON.parseObject(HttpClientUtil.doPost(requestUrl,requestUrlParam));
        return jsonObject;
    }

}
